import type { WorkshopModel } from './models';

import { requestClient } from '#/api/request';

/**
 * 获取车间数据集合
 * @param params 查询参数
 * @returns 返回查询结果
 */
export async function getWorkshopListApi(params?: any) {
  return requestClient.get<WorkshopModel[]>('/mes/master/workshop/list', {
    params,
  });
}

/**
 * 分页查询车间数据集合
 * @param params 分页查询参数
 * @returns 返回查询结果
 */
export async function getWorkshopPagedListApi(params?: PageParams) {
  return requestClient.get<PaginationResult<WorkshopModel>>(
    '/mes/master/workshop/list-page',
    {
      params,
    },
  );
}

/**
 * 创建车间
 * @param data 要创建的车间
 * @returns 返回结果
 */
export async function createWorkshopApi(data: any) {
  return requestClient.post<boolean>('/mes/master/workshop', data);
}

/**
 * 更新车间
 * @param id 车间 Id
 * @param data 要更新的车间数据
 * @returns 返回结果
 */
export async function updateWorkshopApi(id: number, data: any) {
  return requestClient.put<boolean>(`/mes/master/workshop/${id}`, data);
}

/**
 * 删除车间
 * @param id 车间 Id
 * @returns 返回结果
 */
export async function deleteWorkshopApi(id: number) {
  return requestClient.delete<boolean>(`/mes/master/workshop/${id}`);
}
